package com.example.njut;

import android.provider.MediaStore;

import java.io.IOException;

import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;

public class SendCode {

    MediaType JSON = MediaType.parse("application/json;charset=utf-8");
    OkHttpClient client = new OkHttpClient();

    public String post(String url,String json) throws IOException{
        RequestBody body = RequestBody.create(JSON,json);
        Request request = new Request.Builder()
                .url(url)
                .post(body)
                .build();
        try(Response response = client.newCall(request).execute()){
            return response.body().string();
        }
    }

    public String bowlingJson(String checkCode,String phoneNo){
        return "{'sid':'432c1bae10e825d43460be59e7c5a8fb'," +
                " 'token':'2cecdc548211f834df272f009a258b35'," +
                " 'appid':'f0648bdbb987439d86c60c6231ffa885'," +
                " 'templateid':'542631'," +
                " 'param':'"+checkCode+",120'," +
                " 'mobile':'"+phoneNo+"'," +
                " 'uid':''}";
    }
}